package com.beikai.demo01.collection;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : hanbeikai
 * Date: 2021/5/30 4:35 下午
 * Description: No Description
 */
public class ConcurrentHashMapDemo {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ClassNotFoundException {
        ConcurrentHashMap<String,String> con = new ConcurrentHashMap<String,String>(1,0.75f,2);
        con.put("zhangsan","zhangsan");
        con.put("zhangsan2","zhangsan");
        con.put("zhangsan3","zhangsan");
        con.put("zhangsan4","zhangsan");
        con.get("zhangsan");

        HashMap hashMap = new HashMap();
        hashMap.put("zhangsan","zhangsan");

        con.size();

        System.out.println(16 >>> 3);

        int n =  Integer.numberOfLeadingZeros(16) | (1 << (16 - 1));
        System.out.println((n << 16) + 2);
        System.out.println((n << 16) + 1);

        Class<?> aClass = Class.forName("java.util.concurrent.ConcurrentHashMap");
        Method resizeStamp = aClass.getDeclaredMethod("resizeStamp", int.class);
        resizeStamp.setAccessible(true);
        Object invoke = resizeStamp.invoke(aClass.newInstance(), 16);
        System.out.println(invoke);


    }
}
